<?php $this->load->helper('HTML');
echo link_tag('css/style2.css');
echo link_tag('images/favicon.ico','shortcut icon','image/x-icon');
?>
<div id="page1">
<?php $this->load->view('admin_views/header'); ?>
</head>
<style>

.field_error{
	clear:both;
	color:#F00;
	margin-left:150px;
}
</style>
<div id="wrapper">
    <script type="text/javascript">
        $(document).ready( function() {

           $(this).ready( function() {
    		$("#intid_unit").autocomplete({
      			minLength: 2,
      			source:
        		function(req, add){
          			$.ajax({
		        		url: "<?php echo base_url(); ?>penjualan/lookupUnit",
		          		dataType: 'json',
		          		type: 'POST',
						data: req,
		          		success:
		            	function(data){
		              		if(data.response =="true"){
		                 		add(data.message);
		              		}
		            	},
              		});
         		},
         	focus:function(event,ui){var q=$(this).val();$(this).val()=q;},select:
         		function(event, ui) {
            		$("#result").append(
            			"<input type='text' id='intmanager' name='intmanager' value='" + ui.item.value1 + "' size='30' />",
						"<input type='hidden' id='id_unit' name='intid_unit' value='" + ui.item.id + "' size='30' />",
						"<input type='hidden' id='strkode_manager' name='strkode_manager' value='" + ui.item.value2 + "' />"
            		);
         		},
    		});
	    });


            $("#strnama_dealer").autocomplete({
                minLength: 1,
                source:
                    function(req, add){
                    $.ajax({
                        url: "<?php echo base_url(); ?>penjualan/lookupUpline",
                        dataType: 'json',
                        type: 'POST',
                        data: {
                            term: req.term,
                            state: $('#id_unit').val(),
                        },
                        success:
                            function(data){
                            if(data.response =="true"){
                                add(data.message);
                            }
                        },
                    });
                },
                focus:function(event,ui){var q=$(this).val();$(this).val()=q;},select:
                    function(event, ui) {
		    $("#result1").empty();
                    $("#result1").append(
                    "<input type='text' align='top' id='strkode_dealer' name='strkode_dealer' value='" + ui.item.id + "'/><br><input type='text' id='strnama_upline' name='strnama_upline' value='" + ui.item.value2 + "'/><input type='hidden' id='strkode_upline' name='strkode_upline' value='" + ui.item.value1 + "'/>"
                );
                },
            });
        });
    </script></div>

<div id="page">
    <div id="page-bgtop">
        <div id="content">
            <div class="post">  <h2 class="title">REGISTER CALON MANAGER</h2><br>


                <form method="post" action="<?php echo $form_action; ?>">
                    <table width="95%" border="0" cellpadding="0" cellspacing="0" id="data" align="center">

                        <tr>
                            <td>&nbsp;Unit</td>
                            <td><input type="text" name="textfield" id="intid_unit" size="30" />          </td>
                        </tr>
                        <tr>
                            <td>&nbsp;Manager</td>
                            <td><div id="result"></div></td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center"><?php echo form_error('intid_unit', '<p class="field_error">', '</p>');?></td>
                        </tr>
                        
                        <tr>
                            <td  align='left' style='width:25%'>&nbsp;Cari Nama Calon Manager</td>
                            <td><input type="text" name="strnama_dealer" id="strnama_dealer" size="60"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;No Kartu<br />&nbsp;Upline :</td>
                            <td valign="">&nbsp;<div id="result1"></div></td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center"><?php echo form_error('strnama_dealer', '<p class="field_error">', '</p>');?></td>
                        </tr>
                         <tr>
                        <td width="120">Pilih Pengajuan Pra CM Bulan:</td>
                        <td><?php echo $combo_bulan?></td>
                         </tr>
                        <tr>
                            <td><?php echo '<br />'.form_submit('submit','Proses','id="submit" class="button"')?></td>
                        </tr>
                    </table>
                </form>
<?php echo form_error('strkode_dealer', '<p class="field_error">', '</p>');?>
<?php
	echo ! empty($h2_title) ? '<h2>' . $h2_title . '</h2>': '';
	echo ! empty($message) ? '<p class="field_error">' . $message . '</p>': '';

	$flashmessage = $this->session->flashdata('message');
	echo ! empty($flashmessage) ? '<p class="field_error">' . $flashmessage . '</p>': '';
?>
                <h2 class="title" align="center">Data Pra CM</h2><br>
                 <form method="post" action="<?php echo $form_action2?>">
                    <table>
                        <tr>
                            <td>
                                Cari Berdasarkan Nama Dealer &nbsp; <input name="cari_nama" value="" size="30" type="text">
                                    <input type="submit" name="submit" value="Cari">
                            </td>
                        </tr>
                    </table>
                </form>

		        <table width="90%" border="0" cellpadding="1" cellspacing="1" id="data" align="center">
        <thead>
        <tr  align="center" class="table" >
           <th >No</th>
           <th >Kode Dealer</th>
            <th >Nama Dealer</th>
            <th >Unit</th>
            <th >Tanggal Register</th>
            <th>Cabang</th>
            <th>pengajuan<br>Bulan</th>
            <th >Action</th>

        </tr>
    </thead>
    <tbody>

    <!-- ============isi ============ -->

		<?php
        if(!empty($register)){
			$i=1;
			foreach($register as $m) :
            $y = date('Y');
		?>
      	<tr class='data' align='center'>
			<td ><?php echo $i++; ?></td>
			<td align='left'>&nbsp;<?php echo $m->strkode_dealer; ?></td>
            <td align='left'>&nbsp;<?php echo $m->strnama_dealer; ?></td>
            <td align='left'>&nbsp;<?php echo $m->strnama_unit; ?></td>
            <td align='left'>&nbsp;<?php echo $m->tanggal; ?></td>
            <td align='left'>&nbsp;<?php echo $m->cabang; ?></td>
            <td align='center'><?php echo date('F',strtotime($y."-".$m->bulan."-01"));?>
            <td align='left'>&nbsp;<?php echo anchor('calon_manager/hapus_register/'.$m->id,'Hapus',array('class'=> 'delete','onclick'=>"return confirm('Anda yakin akan menghapus data ini?')")) ?></td>

        </tr>
		<?php
        endforeach;
        }else{
        ?>
    <tr>
        <td colspan="6" align="center">
            No Data Display
        </td>
    </tr>
    <?php } ?>

    </tbody>
</table>

            </div>
        </div>

    </div>
    <!-- end #content -->
    <?php $this->load->view('admin_views/sidebar_manager'); ?><!-- end #sidebar -->
    <div style="clear: both;">&nbsp;</div>
</div>

<!-- end #page -->
<div id="footer-bgcontent">
    <?php $this->load->view('admin_views/footer'); ?></div>
<!-- end #footer -->
